import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'

// Nginx打包路由模式可以使hash也可以是history，但是tomcat打包只能是hash
const createFun = createWebHistory
// const createFun = createWebHashHistory
const router = createRouter({
  history: import.meta.env.MODE === 'tomcat' ? createWebHashHistory(import.meta.env.BASE_URL) : createFun(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/login/login.vue')
    },
    {
      path: '/meeting',
      name: 'meeting',
      component: () => import('../views/meeting/meeting.vue')
    },
    {
      path: '/404',
      name: '/404',
      component: () => import('../views/error-page/404.vue'),
      meta: { hidden: true }
    },
    { path: '/:path(.*)', redirect: '/404' }
  ]
})

export default router
